This document is based on v1.2

In order to be able to run the Gui program for BLDC, you will have to register the
Microsoft Communications Active-X Control. For this purpose, you need to have ADMINISTRATOR RIGHTS on your computer.

To do so, please edit the register.bat file and change "c:\winnt" to your own Windows directory.
Then execute the batch file. If the operation succeeded, a Messagebox will appear saying so.
If not, you might not have ADMINISTRATOR RIGHTS.

This version is nearly bug free, the PWM frequency changing capability is not fully tested and bugs remain.
To be sure that the program will work i advise you to use 20kHz. You can change the frequency while running the motor (in hall sensor mode).

The documentation is not released, it will come in the upcoming weeks.

Here is how you can work with it:

********* Setup the environment
- Copy all the files in a directory (any: i.e c:\projects )
- Double click on "register.bat" in the bin directory, this will install the serial port control if not yet installed
- Launch "BLDC Trainer.exe". Usually it gives you an error because the default parameters are not correct.
- Push load button and select c:\projects\BLDC v1.xx\bin\bldc_maxon.parameters
	this is an example file using a Maxon motor
	You are now ready to start playing with BLDC !

********* Setup the system properties
- Go to the System properties tab
- Change the Hall patterns and PWM patterns (by clicking inside the upper array) according to your specific needs (depending on the motor you have)
- Select the bridge modulation, incative state and so on according to your hardware (bridge driver)
- Select first the Hall sensor mode with diagnosis
	The hall sensors should be connected to the C868 the usual way (refer to a reference design for this)
- Disconnect the motor phases from the board, this is very important !
- Push the reset button on your board and the Reload button in the BLDC Trainer. This uploads the software onto the board.

********* Check the Hall Sensors configuration
- Push the start button.
- Go to the System properties tab. By rotating the motor, you should see its current state in the upper array. If you get always '*' around the hall sensors
	it means that your setup is correct. Otherwise you will get '-'. In this mode you can also check (with a scope) that your PWM pattern setup is correct.

********* Run with Hall Sensors
- You can remove the Diagnosis mode.
- Go to the Motor properties tab
- Select a positioning ramp, linear for high inertia motors and exponential for low inertia. The duty cycle should be chosen so the motor will be put in a known position without too much current. You can try different values (start with low values).
- Select the ramp-up you want to apply to your motor. In this case i choose the same value as the positioning sequence without ramp-up (for test purposes).
	We'll see the accelerating part later on.
- Press Start
	The motor should turn, if not check all the parameters. For example, the duty cycle might not sufficient (not enough current)...

********* Prepare for Sensorless
- Now we want to run sensorless, first you need to keep the hall sensor configuration
	Go to system properties and select "record mode" with hall sensors.
	This part of the software records the accelerating phase of the motor.
	The same behaviour will be given to the motor when running sensorless ( the BEMF is too small when motor is at standstill or low speed, therefore we need to accelerate it before)
- Go to the Motor properties tab and push clear table and clear curves
- Push start, after a while you should see a red curve in the graph. This is the curve recorded from the motor itself.
- Push Use curve (if this curve suits you). A blue curve appears, this is the curve which will be stored in the C868 for sensorless operation.

********* Check the accelerating phase
- You are now ready to go sensorless. The sensorless software needs to measure the BEMF from the Motor phases, therefore you need to add voltage dividers.
	These are connected in place of the hall sensors to the SAME inputs. You need to compute the values so that the full voltage extent falls into a 3V range in the end
	(i.e. a 12V motor is connected through a 3/12 voltage divider).
	To sum up you need 3 voltage dividers connected to the 3 ADC inputs.
- Go to the system properties tab and select Sensorless. Please be carefull that hall sensors should not be connected at this time. Same when working with hall sensors, the voltage dividers should not be connected.
- Select the record mode (with sensorless). This will accelerate the motor and show you exactly when the Zero Crossing Event was detected. This is the BEMF Sensorless algorithm.
        If all the curve stays blue, it means your parameters were pretty good. This is not always the case. If the blue color on this curve is really sparse, you should try to change the ramp-up and positioning parameters.
- Press start
	The motor should turn, if not try again. If the motor doesn't work at all, try a different accelerating phase (ramp-up parameters) -> Go back to (18)

********* Running Sensorless
- Remove the record mode
- Press start, the motor should accelerate and turn. If it doesn't, you should tune those 3 parameters (in the motor properties tab):
		Number of points in the table: this gives how many points are recorded. Usually 100 is enough but some motors might need to be accelerated longer before BEMF can be detected.
		Number of events non sampled: this defines a window (from beginning) where the BEMF Sensorless algorithm doesn't work. This should be adjusted to a position where you are sure that the algorithm is working, i.e. close to the end of the curve where it must be all blue (not red).
		Number of events before locking: this defines how many correct Zero Crossing Events should be detected before the algorithm locks onto a normal mode. Adjust it between 3 and 10.

********* Creating your own application
- You can now push the generate button
	This creates 2 files in the bin\C868 directory
- Copy these files into the src\C868 directory and double clik on BLDC.dpt
- You can select the "Normal, Sensorless" target and compile it.
	This is a software which runs without the Gui interface and is the base for a new project....

The final documentation is coming soon.

Enjoy.
